package com.lxit.cms.action.admin.assist.cn.compent;

import java.util.List;

import com.lxit.cms.action.admin.assist.cn.util.SysteLog;

/**
 * ISMG端的SP对象数据的封装,配置对象,配置Bean
 * @desc: 
 * @project:蓝杰中国移动Cmpp短信网关项目开发 Jun 17, 2009
 * @author: 蓝杰www.netjava.cn
 */
public class SPCompany {
	private String spId; //sp的企业ID
	private String spIP;//sp的认证IP
	private String spPWD; //sp登陆密码
	private String spCode;//sp服务号
	
	private int flowLimit;//最大流量
	private int connLimit=4; //连结数限制
	
	//对应的getter/setter方法
	//CMPP连结对象的队列
	private List<CMPPConntor> connList=new java.util.ArrayList();
	 
	//将一条消息发送给自己的SP公司
	public boolean   sendMsg(String srcMobile,String msg,String desSp){
		if(connList.size()>0){
	return 	connList.get(0).sendDeliver(srcMobile,msg,desSp);
		}
		return false;
 	}
	
	/**
	 * 给某个SP对象加入一个连结对象
	 * 1.加入后,要验证
	 * @param conn:cmpp连结对象
	 */
	public void addConn(CMPPConntor conn){
		//验证这个连结
		if(conn.checkLogin(this.spId,this.spPWD)){
			//如果登陆成功了,启动接收线程
			conn.start();
			//将连结放入队列
			connList.add(conn);	
			SysteLog.INFO("SP帐号验证通过","IMSG端接收线程己启动");
		}else{
			SysteLog.ERROR("SP帐号验证","进入SP未验证通过!!!! ");
			conn.close();
		}
		
	}

	public String getSpId() {
		return spId;
	}

	public void setSpId(String spId) {
		this.spId = spId;
	}

	public String getSpIP() {
		return spIP;
	}

	public void setSpIP(String spIP) {
		this.spIP = spIP;
	}

	public String getSpPWD() {
		return spPWD;
	}

	public void setSpPWD(String spPWD) {
		this.spPWD = spPWD;
	}

	public String getSpCode() {
		return spCode;
	}

	public void setSpCode(String spCode) {
		this.spCode = spCode;
	}

	public int getFlowLimit() {
		return flowLimit;
	}

	public void setFlowLimit(int flowLimit) {
		this.flowLimit = flowLimit;
	}

	public int getConnLimit() {
		return connLimit;
	}

	public void setConnLimit(int connLimit) {
		this.connLimit = connLimit;
	}

	public List getConnList() {
		return connList;
	}

	public void setConnList(List connList) {
		this.connList = connList;
	}
	
}
